package com.globallogic.dmytro_zakharenko.university.person;

public class Person {
	
	private String mFirstName;
	private String mLastName;
	private int mDateOfBirth;
	private String mPlaceOfBirth;
	public double mSalary;
	
	/**
	 * Constructor
	 * 
	 * @param firstName
	 * @param lastName
	 * @param dateOfBirth
	 * @param placeOfBirth
	 */
	public Person(String firstName, String lastName, int dateOfBirth, String placeOfBirth, double salary) {
		this.setFirstName(firstName);
		this.setLastName(lastName);
		this.setDateOfBirth(dateOfBirth);
		this.setPlaceOfBirth(placeOfBirth);
		this.setSalary(salary);
	}
	
	/**
	 * set salary for the person
	 * 
	 * @param salary
	 */
	private void setSalary(double salary) {
		this.mSalary = salary;
	}
	
	/**
	 * get person salarys
	 * 
	 * @return mSalary 
	 */
	public double getSalary() {
		return mSalary;
	}
	
	/**
	 * set user specified first name for the person 
	 * 
	 * @param firstName
	 */
	private void setFirstName(String firstName) {
		this.mFirstName = firstName;
	}
	
	/**
	 * get user specified first name for the person 
	 * 
	 * @param mFirstName 
	 */
	public String getFirstName() {
		return mFirstName;
	}
	
	/**
	 * set user specified last name for the person 
	 * 
	 * @param lastName
	 */
	private void setLastName(String lastName) {
		this.mLastName = lastName;
	}

	/**
	 * get user specified last name for the person 
	 * 
	 * @param mLastName 
	 */
	public String getmLastName() {
		return mLastName;
	}
	
	/**
	 * set user specified date of birth for the person 
	 * 
	 * @param dateOfBirth
	 */
	private void setDateOfBirth(int dateOfBirth) {
		this.mDateOfBirth = dateOfBirth;
	}
	
	/**
	 * get user specified date of birth for the person 
	 * 
	 * @param mDateOfBirth 
	 */
	public int getDateOfBirth() {
		return mDateOfBirth;
	}

	/**
	 * set user specified place of birth for the person 
	 * 
	 * @param placeOfBirth
	 */
	private void setPlaceOfBirth(String placeOfBirth) {
		this.mPlaceOfBirth = placeOfBirth;
	}
	
	/**
	 * get user specified place of birth for the person
	 * 
	 * @param mPlaceOfBirth 
	 */
	public String getmPlaceOfBirth() {
		return mPlaceOfBirth;
	}

	@Override
	public int hashCode() {
		return (mFirstName.hashCode() + mLastName.hashCode() 
				+ mPlaceOfBirth.hashCode() + (mDateOfBirth - (int) mSalary));
	}

	@Override
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (other == null)
			return false;
		if (getClass() != other.getClass())
			return false;
		Person otherA = (Person) other;
		return (mFirstName.equalsIgnoreCase(otherA.mFirstName)
				&& mLastName.equalsIgnoreCase(otherA.mLastName)
				&& mPlaceOfBirth.equalsIgnoreCase(otherA.mPlaceOfBirth)
				&& mDateOfBirth == otherA.mDateOfBirth
				&& mSalary == otherA.mSalary);
	}
		
	public String toString() {
		return ("This is person : " + mFirstName + " " + mLastName);
	}
}
